import * as THREE from 'three';

// 创建一个空的几何体对象
const geometry = new THREE.BufferGeometry();

const vertices = new Float32Array([
    0, 0, 0,
    300, 0, 0,
    300, 300, 0,
    -300, 300, 0,
    -300, 0, 0,
    -300, 0, 300,
    -300, 300, 300,
    300, 300, 300,
    300, 0, 300,
    0, 0, 300
])

const attribute = new THREE.BufferAttribute(vertices, 3);
geometry.attributes.position = attribute;

// Uint16Array 类型数组创建顶点索引数据
const indexs = new Uint16Array([
    0, 1, 2, 3, 4, 5
])

// 设置几何体的顶点位置属性
geometry.index = new THREE.BufferAttribute(indexs, 1);

// 定义线材质
const material = new THREE.LineBasicMaterial({
    color: 0x00ff00,
})

// 定义线模型对象 Line、LineSegments、LineLoop
const definedIndex = new THREE.Line(geometry, material);

export default definedIndex;